//
//  ZLPhotoScrollViewController.m
//  TripTogether
//
//  Created by dllo on 15/12/25.
//  Copyright © 2015年 杨泓晔. All rights reserved.
//

#import "ZLPhotoScrollViewController.h"
#import "ZLPhotoCollectionViewCell.h"

@interface ZLPhotoScrollViewController ()<UICollectionViewDataSource, UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,ZLPhotoCollectionViewCellDeletage,PhotoCollectionViewCellDeletage>

@property (nonatomic, strong)UICollectionView *collectionView;
@property (nonatomic, strong)UIImageView *myImageView;

@property (nonatomic, assign) BOOL isShowHeader;

@end

@implementation ZLPhotoScrollViewController

- (void)viewWillAppear:(BOOL)animated {
    
    self.collectionView.contentOffset = CGPointMake(self.num * SCREEN_WIDTH, 0);
    
    self.navigationController.navigationBar.hidden = YES;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    NSLog(@"%ld",self.num);
//    NSLog(@"%@",[[self.zlTapM zlPoiM] name]);
//    NSLog(@"%@",[self.zlTapM model]);
//    NSLog(@"pppp%@",self.myArray);
    
    [self createCollectionView];
}

#pragma mark - 创建CollectionView
- (void)createCollectionView
{
    UICollectionViewFlowLayout *flowLayout = [UICollectionViewFlowLayout new];
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    flowLayout.minimumLineSpacing = 0;
    flowLayout.itemSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT);
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:flowLayout];
    self.collectionView.backgroundColor = [UIColor colorWithRed:0.98 green:0.96 blue:0.91 alpha:1];
    self.collectionView.pagingEnabled = YES;
    self.collectionView.delegate = self;
    self.collectionView.bounces = NO;
    self.collectionView.dataSource = self;
    [self.view addSubview:self.collectionView];
    [self.collectionView registerClass:[ZLPhotoCollectionViewCell class] forCellWithReuseIdentifier:@"ZLPhotoCollectionViewCell"];
   
    
}

#pragma mark - CollectionView协议
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.myArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ZLPhotoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ZLPhotoCollectionViewCell" forIndexPath:indexPath];
    cell.zlTapM = [self.myArray objectAtIndex:indexPath.row];
    cell.photoCollectionViewCellDeletage = self;//轻拍
    cell.photoCollectionVCellDeletage = self;//btn
    
    return cell;
}

//item 高度
//- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
//{
//    return CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT);
//}


#pragma mark - 轻拍图片 协议方法 实现
- (void)tapPhoto:(UIView *)myView view:(UIView *)headView
{
    if (self.isShowHeader) {
        
        [UIView animateWithDuration:1.5 animations:^{
            headView.hidden = NO;
            myView.hidden = NO;
        }];
    }else{
        [UIView animateWithDuration:1.5 animations:^{
            headView.hidden = YES;
            myView.hidden = YES;
        }];
    }
    self.isShowHeader = !self.isShowHeader;
}

#pragma mark - 按钮btn 协议
- (void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)toYouJi
{
    
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
